import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa';
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';

/** 
 * vitePWA 配置
 * https://vite-pwa-org-zh.netlify.app/guide/
 */
const pwaPlugin = VitePWA(
  {
    registerType: 'autoUpdate',
    devOptions:{
      enabled: true
    },
    includeAssets: ['vite.svg'],
    manifest: {
      name: 'My Awesome App',
      short_name: 'MyApp',
      description: 'My Awesome App description',
      theme_color: '#ffffff',
      icons: [
        {
          src: 'vite.svg',
          sizes: '192x192',
          type: 'image/svg+xml',
        },
      ]
    },
  }
)

/**
 * https://github.com/unplugin/unplugin-vue-components
 */
const compsPlugin =  Components({
  resolvers: [
    AntDesignVueResolver({
      importStyle: false, // css in js
    }),
  ],
})

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    pwaPlugin,
    compsPlugin
  ],
})